package com.cdn.allmobilestore.model;

import java.util.ArrayList;


import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.cdn.allmobilestore.ulti.Log;

public class CategoryInfo
{
    private String mCategoryId;
    private String mCategoryName;
    private String mCategoryPhoto;
    private long mTotalCount;
    
    public CategoryInfo(String categoryid, String categoryname,String categoryphoto, long categorytotal)
    {
        this.mCategoryId = categoryid;
        this.mCategoryName = categoryname;
        this.mCategoryPhoto = categoryphoto;
        this.mTotalCount = categorytotal;
    }
    
    public static ArrayList<CategoryInfo> valueOf(JSONObject paramJSONObject) throws JSONException
    {
    //	Log.v("paramJSONObject:" + paramJSONObject.toString());
        ArrayList<CategoryInfo> categoryArray =  new ArrayList<CategoryInfo>();
       // String categories = paramJSONObject.getString("categories");
        JSONArray jsonArr = paramJSONObject.getJSONArray("categories");
        if (jsonArr != null)
        {
            categoryArray = new ArrayList<CategoryInfo>();
            for (int i = 0; i < jsonArr.length(); i++)
            if (!jsonArr.isNull(i))
            {
                JSONObject localJSONObject = jsonArr.getJSONObject(i);
                String str1 = localJSONObject.getString("id");
                String str2 = localJSONObject.getString("name");
                long totalCount = localJSONObject.getLong("hassub");
                categoryArray.add(new CategoryInfo(str1, str2, localJSONObject.getString("iconLink"), totalCount));
            }
        }
        /*categoryArray.add(new CategoryInfo("1","Game",10));
        categoryArray.add(new CategoryInfo("2","Utilities",10));
        categoryArray.add(new CategoryInfo("3","Music & Movie",10));
        categoryArray.add(new CategoryInfo("3","Social Networking",10));
        categoryArray.add(new CategoryInfo("3","Books",10));
        categoryArray.add(new CategoryInfo("3","Education",10));
        categoryArray.add(new CategoryInfo("3","Productivity",10));
        categoryArray.add(new CategoryInfo("1","Game",10));
        categoryArray.add(new CategoryInfo("2","Utilities",10));
        categoryArray.add(new CategoryInfo("3","Music & Movie",10));
        categoryArray.add(new CategoryInfo("3","Social Networking",10));
        categoryArray.add(new CategoryInfo("3","Books",10));
        categoryArray.add(new CategoryInfo("3","Education",10));
        categoryArray.add(new CategoryInfo("3","Productivity",10));
        categoryArray.add(new CategoryInfo("1","Game",10));
        categoryArray.add(new CategoryInfo("2","Utilities",10));
        categoryArray.add(new CategoryInfo("3","Music & Movie",10));
        categoryArray.add(new CategoryInfo("3","Social Networking",10));
        categoryArray.add(new CategoryInfo("3","Books",10));
        categoryArray.add(new CategoryInfo("3","Education",10));
        categoryArray.add(new CategoryInfo("3","Productivity",10));
        categoryArray.add(new CategoryInfo("1","Game",10));
        categoryArray.add(new CategoryInfo("2","Utilities",10));
        categoryArray.add(new CategoryInfo("3","Music & Movie",10));
        categoryArray.add(new CategoryInfo("3","Social Networking",10));
        categoryArray.add(new CategoryInfo("3","Books",10));
        categoryArray.add(new CategoryInfo("3","Education",10));
        categoryArray.add(new CategoryInfo("3","Productivity",10));*/
        return categoryArray;
    }
    
    public String getCategoryId()
    {
        return this.mCategoryId;
    }
    
    public String getName()
    {
        return this.mCategoryName;
    }
    
    public String getPhoto()
    {
        return this.mCategoryPhoto;
    }
    
    public long getTotalCount()
    {
        return this.mTotalCount;
    }
}